package com.dgut.service.background.controller;

import com.alibaba.fastjson.JSON;
import com.dgut.service.background.config.resultConfig.JsonResult;
import com.dgut.service.background.config.resultConfig.ResultTool;
import com.dgut.service.background.entity.Inspector;
import com.dgut.service.background.service.InspectorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 检察员
 */
@RestController
@RequestMapping("inspector")
public class InspectorController {
    @Autowired
    private InspectorService inspectorService;

    @GetMapping("openId/{openId}")
    public String findByOpenId(@PathVariable("openId")String openId){
        Inspector inspector = inspectorService.findByOpenId(openId);
        JsonResult result = ResultTool.success(inspector);
        return JSON.toJSONString(result);
    }
}
